package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.kaishengit.entity.Ideacomment;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class IdeacommentDao {

	private DBHelp<Ideacomment> db = new DBHelp<Ideacomment>();
	
	public void Save (String id,String content,String createtime,String t_employee_id,String t_idea_id) {
		String sql = "insert into t_ideacomment(id,content,createtime,t_employee_id,t_idea_id) values(?,?,?,?,?)";
		db.executeSQL(sql, id,content,createtime,t_employee_id,t_idea_id);
	}
	
	public List<Ideacomment> FindAll () {
		String sql = "select id,content,createtime,t_employee_id,t_idea_id from t_ideacomment";
		return db.executeQueryForList(sql, new IdeacommentRowMapper());
	}
	
	private class IdeacommentRowMapper implements RowMapper<Ideacomment> {
		

		
		public Ideacomment mapperRow (ResultSet rs) throws SQLException {
			
			Ideacomment idc = new Ideacomment();
			idc.setId(rs.getString("id"));
			idc.setContent(rs.getString("content"));
			idc.setCreatetime(rs.getString("createtime"));
			idc.setT_employee_id(rs.getString("t_employee_id"));
			idc.setT_idea_id(rs.getString("t_idea_id"));
			return idc;
		}
	}
}
